package main

import (
	"fmt"
	"runtime"
	"sync"
	"time"
)

func main() {
	start := time.Now()
	var l sync.Mutex
	tag := make(chan string)
	res := make(map[string]string)
	runtime.GOMAXPROCS(2)
	go func() {
		time.Sleep(1 * time.Second)
		l.Lock()
		res["list"] = "my is list"
		//res = append(res, "my is list")
		l.Unlock()
		tag <- "list"
	}()
	go func() {
		time.Sleep(1 * time.Second)
		l.Lock()
		res["total"] = "my is total"
		//res = append(res, "my is total")
		l.Unlock()
		tag <- "total"
	}()
	for i := 0; i < 2; i++ {
		<-tag
		fmt.Println(res)
	}

	fmt.Println(time.Since(start).Seconds())

}
